home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / libf2c-0.000 / libf2c-0 / libf2c / f77 < prev    next >
Encoding:
Text File  |  1995-01-14  |  3.9 KB  |  202 lines

  1. #!/bin/sh
  2. PATH=/v/bin:/bin:/usr/bin
  3. # f77-style shell script to compile and load fortran, C, and assembly codes
  4. #    usage:    f77 [-g] [-O] [-o absfile] [-c] files [-l library]
  5. #        -o objfile    Override default executable name a.out.
  6. #        -c        Do not call linker, leave relocatables in *.o.
  7. #        -S        leave assembler output on file.s
  8. #        -l library    (passed to ld).
  9. #        -u        complain about undeclared variables
  10. #        -w        omit all warning messages
  11. #        -w66        omit Fortran 66 compatibility warning messages
  12. #        files        FORTRAN source files ending in .f .
  13. #                C source files ending in .c .
  14. #                Assembly language files ending in .s .
  15. #                efl source files ending in .e .
  16. #        -I includepath    passed to C compiler (for .c files)
  17. #        -Ntnnn        allow nnn entries in table t
  18. #        -cpp -Dxxx    pipe through cpp
  19.  
  20. s=/tmp/stderr_$$
  21. t=/tmp/f77_$$
  22. CC=${CC_f2c:-'/usr/bin/cc -m486'}
  23. EFL=${EFL:-/v/bin/efl}
  24. EFLFLAGS=${EFLFLAGS:-'system=portable deltastno=10'}
  25. F2C=${F2C:-/usr/bin/f2c}
  26. F2CFLAGS=${F2CFLAGS:='-ARw8 -Nn802'}
  27. rc=0
  28. lib=/lib/num/lib.lo
  29. trap "rm -f $s ; exit \$rc" 0
  30. OUTF=a.out
  31. cOPT=1
  32. G=
  33. CPP=/bin/cat
  34. CPPFLAGS=
  35. # set -- `getopt cD:gI:N:Oo:Suw6 "$@"`
  36. case $? in 0);; *) exit 1;; esac
  37. CCFLAGS=
  38. while
  39.     test X"$1" != X--
  40. do
  41.     case "$1"
  42.     in
  43.     -c)    cOPT=0
  44.         shift
  45.         ;;
  46.  
  47.     -D)    CPPFLAGS="$CPPFLAGS -D$2"
  48.         shift 2
  49.         ;;
  50.  
  51.     -D*)    CPPFLAGS="$CPPFLAGS $1"
  52.         shift 1
  53.         ;;
  54.  
  55.     -g)    CFLAGS="$CFLAGS -g -static"
  56.         CCFLAGS="$CCFLAGS -g -static"
  57.         F2CFLAGS="$F2CFLAGS -g"
  58.         G="-g"
  59.         shift;;
  60.  
  61.     -I)    CCFLAGS="$CCFLAGS -I$2"
  62.         shift 2
  63.         ;;
  64.  
  65.     -I*)    CCFLAGS="$CCFLAGS $1"
  66.         shift 1
  67.         ;;
  68.  
  69.     -o)    OUTF=$2
  70.         shift 2
  71.         ;;
  72.  
  73.     -O|-O1|-O2)
  74.         CCFLAGS="$CCFLAGS $1"
  75.         shift
  76.         ;;
  77.  
  78.     -u)    F2CFLAGS="$F2CFLAGS -u"
  79.         shift
  80.         ;;
  81.  
  82.     -w)    F2CFLAGS="$F2CFLAGS -w"
  83.         case $2 in -6) F2CFLAGS="$F2CFLAGS"66; shift
  84.             case $2 in -6) shift;; esac;; esac
  85.         shift
  86.         ;;
  87.  
  88.     -N)    F2CFLAGS="$F2CFLAGS $1""$2"
  89.         shift 2
  90.         ;;
  91.  
  92.     -N*|-C)    F2CFLAGS="$F2CFLAGS $1"
  93.         shift 1
  94.         ;;
  95.  
  96.     -cpp)    CPP="/lib/cpp -traditional"
  97.         shift 1
  98.         ;;
  99.  
  100.     -S)    CFLAGS="$CFLAGS -S"
  101.         cOPT=0
  102.         shift
  103.         ;;
  104.  
  105.     -*)
  106.         echo "invalid parameter $1" 1>&2
  107.         shift
  108.         ;;
  109.  
  110.     *)    set -- -- $@
  111.         ;;
  112.     esac
  113. done
  114. shift
  115.  
  116. while
  117.     test -n "$1"
  118. do
  119.     case "$1"
  120.     in
  121.     *.[fF])
  122.         case "$1" in *.f) f=".f";; *.F) f=".F";; esac
  123.         b=`basename $1 $f`
  124.                 trap "rm -f f2ctmp_$b.* ; exit 4" 0
  125.                 sed 's/\\$/\\-/' $1| $CPP $CPPFLAGS  > f2ctmp_$b.f
  126.                 trap "rm -f f2ctmp_$b.* ; exit 4" 0
  127.         $F2C $F2CFLAGS f2ctmp_$b.f
  128.         case $? in 0);; *) rm f2ctmp_* ; exit 5;; esac
  129.                 rm -f f2ctmp_$b.f
  130.         mv f2ctmp_$b.c $b.c
  131.         if [ -f f2ctmp_$b.P ]; then mv f2ctmp_$b.P $b.P; fi
  132.         case $? in 0);; *) rm -f $b.c ; exit 5;; esac
  133.                 trap "rm -f $s ; exit 4" 0
  134.                 $CC $CPPFLAGS -c $CFLAGS $b.c 2>$s
  135.         rc=$?
  136.         sed '/parameter .* is not referenced/d;/warning: too many parameters/d' $s 1>&2
  137.         case $rc in 0);; *) exit 5;; esac
  138.         rm -f $b.c
  139.         OFILES="$OFILES $b.o"
  140.         case $cOPT in 1) cOPT=2;; esac
  141.         shift
  142.         ;;
  143.     *.e)
  144.         b=`basename $1 .e`
  145.         $EFL $EFLFLAGS $1 >$b.f
  146.         case $? in 0);; *) exit;; esac
  147.         $F2C $F2CFLAGS $b.f
  148.         case $? in 0);; *) exit;; esac
  149.                 $CC -c $CFLAGS $b.c
  150.         case $? in 0);; *) exit;; esac
  151.         OFILES="$OFILES $b.o"
  152.         rm $b.[cf]
  153.         case $cOPT in 1) cOPT=2;; esac
  154.         shift
  155.         ;;
  156.     *.s)
  157.         echo $1: 1>&2
  158.         OFILE=`basename $1 .s`.o
  159.         ${AS:-/usr/bin/as} -o $OFILE $AFLAGS $1
  160.         case $? in 0);; *) exit;; esac
  161.         OFILES="$OFILES $OFILE"
  162.         case $cOPT in 1) cOPT=2;; esac
  163.         shift
  164.         ;;
  165.     *.c)
  166.         echo $1: 1>&2
  167.         OFILE=`basename $1 .c`.o
  168.                 $CC -c $CFLAGS $CCFLAGS $CPPFLAGS $1
  169.         rc=$?; case $rc in 0);; *) exit;; esac
  170.         OFILES="$OFILES $OFILE"
  171.         case $cOPT in 1) cOPT=2;; esac
  172.         shift
  173.         ;;
  174.     *.o)
  175.         OFILES="$OFILES $1"
  176.         case $cOPT in 1) cOPT=2;; esac
  177.         shift
  178.         ;;
  179.     -l)
  180.         OFILES="$OFILES -l$2"
  181.         shift 2
  182.         case $cOPT in 1) cOPT=2;; esac
  183.         ;;
  184.     -l*)
  185.         OFILES="$OFILES $1"
  186.         shift
  187.         case $cOPT in 1) cOPT=2;; esac
  188.         ;;
  189.     -o)
  190.         OUTF=$2; shift 2;;
  191.     *)
  192.         OFILES="$OFILES $1"
  193.         shift
  194.         case $cOPT in 1) cOPT=2;; esac
  195.         ;;
  196.     esac
  197. done
  198.  
  199. case $cOPT in 2) $CC $G -o $OUTF $OFILES -lf2c -lm;; esac
  200. rc=$?
  201. exit $rc
  202.